home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 3
/
ct-rom iiib.zip
/
ct-rom iiib
/
CTSELECT
/
TERMINAT
/
0150TER2._XE
/
PASCAL.EXE
/
TEXT_XLT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-06-07
|
2KB
|
79 lines
Uses Dos;
Var
FromF, ToF, F : File;
TableNote : String[54];
InTable, OutTable : Array[0..255] of Byte;
X, NumRead, NumWritten : Word;
Buf : array[1..32768] of Byte;
UseIn : Boolean;
EraseAfter : Boolean;
Function UpStr(s:String):String;
Var i : byte;
Begin
for i := 1 to Length(s) do s[i] := UpCase(s[i]);
upstr:=s;
End;
Begin
WriteLn('Translate documents using Terminate XLT files');
If ParamCount<3 Then
Begin
WriteLn(#10'Syntax: TEXT_XLT xlt-file file-to-convert in/out [erase]');
WriteLn(' TEXT_XLT ISOLAT-1.XLT TEST.TXT IN');
WriteLn(' TEXT_XLT DK-7BIT.XLT TEST.TXT OUT ERASE');
WriteLn(#10'Erase will delete the original file and rename the new file back');
Halt;
End;
EraseAfter:=False; If UpStr(Paramstr(4))='ERASE' Then EraseAfter:=True;
UseIn:=True; If UpStr(Paramstr(3))='OUT' Then UseIn:=False;
Assign(F,Paramstr(1));
{$I-} Reset(F,1); {$I+}
If IOResult=0 Then
Begin
BlockRead(F,TableNote,Sizeof(TableNote));
WriteLn('Table: '+TableNote);
BlockRead(F,InTable,256);
BlockRead(F,OutTable,256);
{$I-} Close(F); {$I+}
End
Else Begin
WriteLn('Could not open '+Paramstr(1));
Halt;
End;
WriteLn('Comment: '+TableNote);
Assign(FromF, ParamStr(2)); Reset(FromF, 1);
Assign(ToF, 'TEXT_XLT.TXT'); Rewrite(ToF, 1);
If UseIn Then WriteLn('Using incoming table')
Else WriteLn('Using outgoing table');
Writeln('Converting ', FileSize(FromF), ' bytes...');
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
If UseIn Then
For x:=1 to NumRead Do Buf[x]:=InTable[Buf[x]]
Else
For x:=1 to NumRead Do Buf[x]:=OutTable[Buf[x]];
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
Close(FromF);
Close(ToF);
If EraseAfter Then
Begin
Erase(FromF);
Rename(ToF,ParamStr(2));
WriteLn(ParamStr(2)+' has been converted');
End
Else WriteLn('TEXT_XLT.TXT created');
End.